
libmad=../../src/libmad/decoder.c ../../src/libmad/frame.c ../../src/libmad/bit.c ../../src/libmad/stream.c ../../src/libmad/fixed.c \
../../src/libmad/timer.c ../../src/libmad/layer3.c ../../src/libmad/synth.c ../../src/libmad/huffman.c ../../src/libmad/version.c
 

libhelix_mp3=../../src/libhelix-mp3/dequant.c ../../src/libhelix-mp3/mp3dec.c ../../src/libhelix-mp3/stproc.c \
../../src/libhelix-mp3/hufftabs.c ../../src/libhelix-mp3/dct32.c ../../src/libhelix-mp3/trigtabs.c \
../../src/libhelix-mp3/dqchan.c ../../src/libhelix-mp3/scalfact.c ../../src/libhelix-mp3/polyphase.c ../../src/libhelix-mp3/buffers.c \
../../src/libhelix-mp3/bitstream.c ../../src/libhelix-mp3/imdct.c ../../src/libhelix-mp3/subband.c ../../src/libhelix-mp3/huffman.c \
../../src/libhelix-mp3/mp3tabs.c

audiolib=../../src/AudioGeneratorWAV.cpp ../../src/AudioGeneratorMIDI.cpp ../../src/AudioFileSourceSTDIO.cpp ../../src/AudioOutputSTDIO.cpp \
../../src/AudioFileSourceID3.cpp ../../src/AudioGeneratorAAC.cpp ../../src/AudioGeneratorMP3.cpp ../../src/AudioOutputFilterDecimate.cpp \
../../src/AudioGeneratorFLAC.cpp ../../src/AudioGeneratorMOD.cpp ../../src/AudioFileSourceBuffer.cpp ../../src/AudioGeneratorMP3a.cpp \
Serial.cpp

libhelix_aac=../../src/libhelix-aac/decelmnt.c ../../src/libhelix-aac/dct4.c ../../src/libhelix-aac/dequant.c ../../src/libhelix-aac/sbrhuff.c \
../../src/libhelix-aac/sbrmath.c ../../src/libhelix-aac/aactabs.c ../../src/libhelix-aac/stproc.c ../../src/libhelix-aac/hufftabs.c \
../../src/libhelix-aac/sbrtabs.c ../../src/libhelix-aac/sbrfft.c ../../src/libhelix-aac/filefmt.c ../../src/libhelix-aac/tns.c \
../../src/libhelix-aac/trigtabs.c ../../src/libhelix-aac/fft.c ../../src/libhelix-aac/pns.c ../../src/libhelix-aac/sbrfreq.c \
../../src/libhelix-aac/sbrside.c ../../src/libhelix-aac/sbrhfadj.c ../../src/libhelix-aac/buffers.c ../../src/libhelix-aac/bitstream.c \
../../src/libhelix-aac/noiseless.c ../../src/libhelix-aac/imdct.c ../../src/libhelix-aac/aacdec.c ../../src/libhelix-aac/sbrhfgen.c \
../../src/libhelix-aac/sbrqmf.c ../../src/libhelix-aac/huffman.c ../../src/libhelix-aac/sbr.c ../../src/libhelix-aac/sbrimdct.c

libflac=../../src/libflac/md5.c ../../src/libflac/window.c ../../src/libflac/memory.c ../../src/libflac/cpu.c ../../src/libflac/fixed.c \
../../src/libflac/format.c ../../src/libflac/lpc.c ../../src/libflac/crc.c ../../src/libflac/bitreader.c ../../src/libflac/bitmath.c \
../../src/libflac/stream_decoder.c ../../src/libflac/float.c

libogg=../../src/libogg/framing.c ../../src/libogg/bitwise.c

libopus=../../src/libopus/opus_decoder.c ../../src/libopus/opus_projection_decoder.c ../../src/libopus/opus.c ../../src/libopus/opus_multistream.c \
../../src/libopus/opus_multistream_encoder.c ../../src/libopus/repacketizer.c ../../src/libopus/opus_multistream_decoder.c \
../../src/libopus/mapping_matrix.c ../../src/libopus/opus_projection_encoder.c ../../src/libopus/silk/NLSF_VQ_weights_laroia.c \
../../src/libopus/silk/decode_core.c ../../src/libopus/silk/resampler_down2_3.c ../../src/libopus/silk/resampler_private_down_FIR.c \
../../src/libopus/silk/tables_other.c ../../src/libopus/silk/resampler_private_up2_HQ.c ../../src/libopus/silk/init_encoder.c \
../../src/libopus/silk/tables_NLSF_CB_WB.c ../../src/libopus/silk/control_codec.c ../../src/libopus/silk/decode_frame.c \
../../src/libopus/silk/table_LSF_cos.c ../../src/libopus/silk/resampler_private_AR2.c ../../src/libopus/silk/NLSF_del_dec_quant.c \
../../src/libopus/silk/VQ_WMat_EC.c ../../src/libopus/silk/encode_indices.c ../../src/libopus/silk/sort.c ../../src/libopus/silk/NSQ.c \
../../src/libopus/silk/NLSF_unpack.c ../../src/libopus/silk/bwexpander_32.c ../../src/libopus/silk/tables_NLSF_CB_NB_MB.c \
../../src/libopus/silk/ana_filt_bank_1.c ../../src/libopus/silk/resampler_down2.c ../../src/libopus/silk/stereo_encode_pred.c \
../../src/libopus/silk/bwexpander.c ../../src/libopus/silk/PLC.c ../../src/libopus/silk/pitch_est_tables.c ../../src/libopus/silk/NLSF2A.c \
../../src/libopus/silk/stereo_quant_pred.c ../../src/libopus/silk/debug.c ../../src/libopus/silk/LPC_analysis_filter.c \
../../src/libopus/silk/control_audio_bandwidth.c ../../src/libopus/silk/decode_indices.c ../../src/libopus/silk/sigm_Q15.c \
../../src/libopus/silk/resampler_private_IIR_FIR.c ../../src/libopus/silk/log2lin.c ../../src/libopus/silk/A2NLSF.c \
../../src/libopus/silk/quant_LTP_gains.c ../../src/libopus/silk/NLSF_stabilize.c ../../src/libopus/silk/fixed/find_pred_coefs_FIX.c \
../../src/libopus/silk/fixed/autocorr_FIX.c ../../src/libopus/silk/fixed/burg_modified_FIX.c ../../src/libopus/silk/fixed/vector_ops_FIX.c \
../../src/libopus/silk/fixed/find_LTP_FIX.c ../../src/libopus/silk/fixed/find_pitch_lags_FIX.c ../../src/libopus/silk/fixed/schur64_FIX.c \
../../src/libopus/silk/fixed/noise_shape_analysis_FIX.c ../../src/libopus/silk/fixed/find_LPC_FIX.c \
../../src/libopus/silk/fixed/residual_energy16_FIX.c ../../src/libopus/silk/fixed/apply_sine_window_FIX.c \
../../src/libopus/silk/fixed/regularize_correlations_FIX.c ../../src/libopus/silk/fixed/k2a_Q16_FIX.c \
../../src/libopus/silk/fixed/encode_frame_FIX.c ../../src/libopus/silk/fixed/k2a_FIX.c ../../src/libopus/silk/fixed/pitch_analysis_core_FIX.c \
../../src/libopus/silk/fixed/process_gains_FIX.c ../../src/libopus/silk/fixed/LTP_scale_ctrl_FIX.c \
../../src/libopus/silk/fixed/warped_autocorrelation_FIX.c ../../src/libopus/silk/fixed/schur_FIX.c \
../../src/libopus/silk/fixed/LTP_analysis_filter_FIX.c ../../src/libopus/silk/fixed/corrMatrix_FIX.c \
../../src/libopus/silk/fixed/residual_energy_FIX.c ../../src/libopus/silk/LPC_fit.c ../../src/libopus/silk/tables_gain.c \
../../src/libopus/silk/decode_parameters.c ../../src/libopus/silk/tables_pitch_lag.c ../../src/libopus/silk/stereo_MS_to_LR.c \
../../src/libopus/silk/dec_API.c ../../src/libopus/silk/code_signs.c ../../src/libopus/silk/shell_coder.c \
../../src/libopus/silk/stereo_find_predictor.c ../../src/libopus/silk/init_decoder.c ../../src/libopus/silk/decode_pulses.c \
../../src/libopus/silk/gain_quant.c ../../src/libopus/silk/check_control_input.c ../../src/libopus/silk/tables_LTP.c \
../../src/libopus/silk/resampler_rom.c ../../src/libopus/silk/NSQ_del_dec.c ../../src/libopus/silk/decode_pitch.c ../../src/libopus/silk/VAD.c \
../../src/libopus/silk/NLSF_decode.c ../../src/libopus/silk/sum_sqr_shift.c ../../src/libopus/silk/stereo_LR_to_MS.c \
../../src/libopus/silk/encode_pulses.c ../../src/libopus/silk/control_SNR.c ../../src/libopus/silk/tables_pulses_per_block.c \
../../src/libopus/silk/LP_variable_cutoff.c ../../src/libopus/silk/enc_API.c ../../src/libopus/silk/interpolate.c \
../../src/libopus/silk/LPC_inv_pred_gain.c ../../src/libopus/silk/NLSF_VQ.c ../../src/libopus/silk/lin2log.c \
../../src/libopus/silk/resampler.c ../../src/libopus/silk/NLSF_encode.c ../../src/libopus/silk/CNG.c ../../src/libopus/silk/stereo_decode_pred.c \
../../src/libopus/silk/process_NLSFs.c ../../src/libopus/silk/HP_variable_cutoff.c ../../src/libopus/silk/biquad_alt.c \
../../src/libopus/silk/inner_prod_aligned.c ../../src/libopus/silk/decoder_set_fs.c ../../src/libopus/celt/celt.c \
../../src/libopus/celt/mdct.c ../../src/libopus/celt/cwrs.c ../../src/libopus/celt/rate.c ../../src/libopus/celt/vq.c \
../../src/libopus/celt/quant_bands.c ../../src/libopus/celt/celt_decoder.c ../../src/libopus/celt/celt_lpc.c \
../../src/libopus/celt/celt_encoder.c ../../src/libopus/celt/entenc.c ../../src/libopus/celt/bands.c ../../src/libopus/celt/kiss_fft.c \
../../src/libopus/celt/pitch.c ../../src/libopus/celt/entdec.c ../../src/libopus/celt/laplace.c ../../src/libopus/celt/entcode.c \
../../src/libopus/celt/modes.c ../../src/libopus/celt/mathops.c ../../src/libopus/opus_encoder.c

opusfile=../../src/opusfile/opusfile.c ../../src/opusfile/stream.c ../../src/opusfile/internal.c ../../src/opusfile/info.c

libflac=../../src/libflac/md5.c ../../src/libflac/window.c ../../src/libflac/memory.c ../../src/libflac/cpu.c \
../../src/libflac/fixed.c ../../src/libflac/format.c ../../src/libflac/lpc.c ../../src/libflac/crc.c \
../../src/libflac/bitreader.c ../../src/libflac/bitmath.c ../../src/libflac/stream_decoder.c ../../src/libflac/float.c


CCOPTS=-g -Wunused-parameter -Wall -m32 -include Arduino.h -Wstack-usage=300
CPPOPTS=-g -Wunused-parameter -Wall -std=c++11 -m32 -Wstack-usage=300 -include Arduino.h

.phony: all

all: mp3 aac wav midi opus flac mod

mp3: FORCE
	rm -f *.o
	gcc $(CCOPTS) -c $(libmad) -I ../../src/ -I.
	g++ $(CPPOPTS) -o mp3 mp3.cpp Serial.cpp *.o ../../src/AudioFileSourceSTDIO.cpp ../../src/AudioOutputSTDIO.cpp ../../src/AudioFileSourceID3.cpp ../../src/AudioFileSourceBuffer.cpp ../../src/AudioGeneratorMP3.cpp ../../src/AudioOutputMixer.cpp ../../src/AudioLogger.cpp  -I ../../src/ -I.
	rm -f *.o
	echo valgrind --leak-check=full --track-origins=yes -v --error-limit=no --show-leak-kinds=all ./mp3

aac: FORCE
	rm -f *.o
	gcc $(CCOPTS) -DUSE_DEFAULT_STDLIB -c $(libhelix_aac) -I ../../src/ -I.
	g++ $(CPPOPTS) -o aac aac.cpp Serial.cpp *.o ../../src/AudioFileSourceSTDIO.cpp ../../src/AudioOutputSTDIO.cpp ../../src/AudioFileSourceID3.cpp ../../src/AudioGeneratorAAC.cpp  ../../src/AudioLogger.cpp -I ../../src/ -I.
	rm -f *.o
	echo valgrind --leak-check=full --track-origins=yes -v --error-limit=no --show-leak-kinds=all ./aac

flac: FORCE
	rm -f *.o
	gcc $(CCOPTS) -DUSE_DEFAULT_STDLIB -c $(libflac) -I ../../src/ -I ../../src/libflac -I.
	g++ $(CPPOPTS) -o flac flac.cpp Serial.cpp *.o ../../src/AudioFileSourceSTDIO.cpp ../../src/AudioOutputSTDIO.cpp ../../src/AudioFileSourceID3.cpp ../../src/AudioGeneratorFLAC.cpp  ../../src/AudioLogger.cpp -I ../../src/ -I.
	rm -f *.o
	echo valgrind --leak-check=full --track-origins=yes -v --error-limit=no --show-leak-kinds=all ./flac

mod: FORCE
	rm -f *.o
	g++ $(CPPOPTS) -o mod mod.cpp Serial.cpp ../../src/AudioFileSourcePROGMEM.cpp ../../src/AudioOutputSTDIO.cpp ../../src/AudioGeneratorMOD.cpp  ../../src/AudioLogger.cpp -I ../../src/ -I.
	rm -f *.o
	echo valgrind --leak-check=full --track-origins=yes -v --error-limit=no --show-leak-kinds=all ./mod

wav: FORCE
	rm -f *.o
	g++ $(CPPOPTS) -o wav wav.cpp Serial.cpp  ../../src/AudioFileSourceSTDIO.cpp ../../src/AudioOutputSTDIO.cpp ../../src/AudioGeneratorWAV.cpp   ../../src/AudioLogger.cpp -I ../../src/ -I.
	rm -f *.o
	echo valgrind --leak-check=full --track-origins=yes -v --error-limit=no --show-leak-kinds=all ./wav

midi: FORCE
	rm -f *.o
	g++ $(CPPOPTS) -o midi midi.cpp Serial.cpp  ../../src/AudioFileSourceSTDIO.cpp ../../src/AudioOutputSTDIO.cpp ../../src/AudioGeneratorMIDI.cpp   ../../src/AudioLogger.cpp -I ../../src/ -I.
	rm -f *.o
	echo valgrind --leak-check=full --track-origins=yes -v --error-limit=no --show-leak-kinds=all ./midi

opus: FORCE
	rm -f *.o
	gcc $(CCOPTS) -DUSE_DEFAULT_STDLIB -c $(libogg) -I ../../src/ -I.
	gcc $(CCOPTS) -DUSE_DEFAULT_STDLIB -c $(libopus) -I ../../src/ -I.
	gcc $(CCOPTS) -DUSE_DEFAULT_STDLIB -c $(opusfile) -I ../../src/ -I.
	g++ $(CPPOPTS) -o opus opus.cpp Serial.cpp *.o ../../src/AudioFileSourceSTDIO.cpp ../../src/AudioOutputSTDIO.cpp ../../src/AudioGeneratorOpus.cpp  ../../src/AudioLogger.cpp -I ../../src/ -I.
	rm -f *.o
	echo valgrind --leak-check=full --track-origins=yes -v --error-limit=no --show-leak-kinds=all ./opus

clean:
	rm -f mp3 aac wav midi opus flac mod *.o

FORCE:
